var a = getApp();

Page({
    data: {
        btnStatus: !1,
        page: 1
    },
    onLoad: function(e) {
        if (this.getData(), e.scene) {
            var t = decodeURIComponent(e.scene);
            if (t) {
                var o = [];
                o = t.split(",");
                for (var n = 0; n < o.length; n++) {
                    var r;
                    "mid" == (r = o[n].split("="))[0] && a._setMid(r[1]);
                }
            }
        }
    },
    tapUrl: function(a) {
        var e = a.currentTarget.dataset.url;
        try {
            wx.navigateTo({
                url: e
            });
        } catch (a) {
            console.log(a);
        }
    },
    goSearch: function() {
        wx.navigateTo({
            url: "/packageE/groupCode/groupCodeSearch/groupCodeSearch"
        });
    },
    toDetails: function(a) {
        var e = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageE/groupCode/groupCodeLabel/groupCodeLabel?id=" + e
        });
    },
    onReady: function() {},
    creation: function(a) {
        wx.navigateTo({
            url: "/packageE/groupCode/groupCodeCreate/groupCodeCreate"
        });
    },
    record: function(a) {
        wx.navigateTo({
            url: "/packageE/groupCode/groupCodeRecord/groupCodeRecord"
        });
    },
    chooseSta: function() {
        this.setData({
            btnStatus: !this.data.btnStatus
        });
    },
    rankTap: function(a) {
        wx.navigateTo({
            url: "/packageE/groupCode/groupCodeRanking/groupCodeRanking"
        });
    },
    onShow: function() {
        this.setData({
            btnStatus: !1,
            page: 1
        }), this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (console.log("111111111111111111111111"), !(this.data.current_page >= this.data.last_page)) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getMore();
        }
    },
    onShareAppMessage: function() {},
    getData: function() {
        var e = this, t = a.getNetAddresss("plugin.group-code.api.group-code.index");
        a._postNetWork({
            url: t,
            data: {
                page: e.data.page
            },
            success: function(a) {
                var t = a.data;
                1 == t.result ? (console.log(t), e.setData({
                    info: t.data,
                    current_page: t.data.recommend.current_page,
                    last_page: t.data.recommend.last_page
                })) : (wx.showToast({
                    title: t.msg,
                    icon: "none"
                }), console.log(t.msg));
            }
        });
    },
    getMore: function() {
        var e = this, t = a.getNetAddresss("plugin.group-code.api.group-code.index");
        a._postNetWork({
            url: t,
            data: {
                page: e.data.page
            },
            success: function(a) {
                var t = a.data;
                1 == t.result ? (console.log(t), t.data.recommend.data = e.data.info.recommend.data.concat(t.data.recommend.data), 
                e.setData({
                    info: t.data,
                    current_page: t.data.recommend.current_page,
                    last_page: t.data.recommend.last_page
                })) : (wx.showToast({
                    title: t.msg,
                    icon: "none"
                }), console.log(t.msg));
            }
        });
    }
});